﻿<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../StaticFiles/element-ui/element-ui.css">
  <link rel="stylesheet" href="../StaticFiles/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../styles/vue-page-common.css">
  <script src="../Scripts/vue.min.js"></script>
  <script src="../StaticFiles/element-ui/element-ui.js"></script>
  <script src="../Scripts/axios.min.js"></script>
  <script src="../StaticFiles/nprogress/nprogress.min.js"></script>
  <script src="../Scripts/dayjs.min.js"></script>
  <script src="../Scripts/axios.config.js"></script>
  <title>零件流转信息查询报表</title>
</head>

<body>
  <div id="app" v-cloak v-on:keyup.enter="getData">
    <!-- 报表标题 -->
    <vue2-report-header :title="queryInfo.factoryname+'零件流转信息查询报表'"></vue2-report-header>
    <div style="padding: 10px;" id="queryZone">
      <!-- 查询条件区 -->
      <el-form :inline="true" :model="queryInfo" ref="queryInfoRef" :label-position="'left'" :rules="rules">
        <el-form-item label="主制分厂:" prop="factoryid">
          <el-select v-model="queryInfo.factoryid" placeholder="请选择" clearable filterable>
            <el-option v-for="f in factoryList" :key="f.factoryid" :label="f.factoryname" :value="f.factoryid">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item prop='mfgordername' label="订单号:">
          <el-autocomplete v-model.trim="queryInfo.mfgordername" placeholder="请输入订单号" :trigger-on-focus="false"
            :fetch-suggestions="searchMfgorderAsync" :value-key="'mfgordername'" :debounce="500" style="width:200px;">
          </el-autocomplete>
        </el-form-item>

        <el-form-item prop='productname' label="件号:">
          <el-autocomplete v-model.trim="queryInfo.productname" placeholder="请输入件号" :trigger-on-focus="false"
            :fetch-suggestions="searchProductAsync" :value-key="'productname'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item prop='containername' label="流水卡号:">
          <el-autocomplete v-model.trim="queryInfo.containername" placeholder="请输入流水卡号" :trigger-on-focus="false"
            :fetch-suggestions="searchContainerAsync" :value-key="'containername'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="getData">查询</el-button>
          <el-button type="primary" icon="el-icon-download" size="small" @click="getExportExcel">导出</el-button>
        </el-form-item>
      </el-form>

      <!-- 表格显示区 -->
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="dataList" stripe border>
        <el-table-column type="index" width="50"></el-table-column>
        <el-table-column label="订单号" prop="mfgordername" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="型别" prop="familylistnames" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件号" prop="productname" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件名称" prop="productdescription" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="流水卡号" prop="containername" width="180" show-overflow-tooltip></el-table-column>
        <el-table-column label="当前工序" prop="currentworkflowstepname" width="160" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="数量" prop="qty" width="60" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序号" prop="specno" width="60" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序名称" prop="opdesc" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序完工时间" prop="checkdate" width="120" show-overflow-tooltip>
          <template slot-scope="scope" v-if="scope.row.checkdate">
            <el-tag type="success">{{scope.row.checkdate.split('T')[0]}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="工序主制分厂" prop="factoryname" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序主制工区" prop="workcentername" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="转工状态" prop="status" width="80" show-overflow-tooltip>
          <template slot-scope="scope" v-if="scope.row.status">
            <el-tag v-if="scope.row.status === '已转入'" type="success">{{scope.row.status}}</el-tag>
            <el-tag v-else>{{scope.row.status}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="转出时间" prop="senddate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="转出人" prop="sender" width="60" show-overflow-tooltip></el-table-column>
        <el-table-column label="要求完成时间" prop="needcompletedate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="接收时间" prop="toacceptdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="接收人" prop="toacceptor" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="预计完成时间" prop="estimatedcompletedate" width="100" :formatter="splitDate">
        </el-table-column>
        <el-table-column label="完成时间" prop="completedate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="转入时间" prop="recivedate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="转入人" prop="returnemp" width="60" show-overflow-tooltip></el-table-column>
        <el-table-column label="下工序号" prop="nextspecno" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="下工序名称" prop="nextopdesc" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="下工序主制分厂" prop="nextfactoryname" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="下工序主制工区" prop="nextworkcentername" width="120" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="下工序完工时间" prop="nextcheckdate" width="120" :formatter="splitDate"></el-table-column>
      </el-table>

      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="queryInfo.currentPage" :page-sizes="[20,50,100]" :page-size="queryInfo.pageSize"
        layout="prev,pager,next,jumper,sizes,total" :total="total">
      </el-pagination>

      <!-- 回到顶部 -->
      <el-backtop></el-backtop>
    </div>
  </div>

  <script type="module">
    import { getParams, fetchSuggestion, exportExcelData } from '../Scripts/hooks/useCommonMethod.js'
    import { getFactoryListByCode } from '../Scripts/hooks/fetchAPI.js'
    import { splitDate } from '../Scripts/hooks/format.js'
    import Vue2ReportHeader from '../Scripts/components/Vue2ReportHeader.js'
    const app = new Vue({
      el: '#app',
      components: { Vue2ReportHeader },
      data: {
        splitDate,
        total: 0,
        loading: false,
        loadingText: '数据加载中...',
        queryInfo: {
          factoryid: '',
          factoryname: '',
          mfgordername: '',
          productname: '',
          containername: '',
          currentPage: 1,//当前页
          pageSize: 20//每页显示条数
        },
        factoryList: [],
        dataList: [],
        userInfo: {},
        rules: {
          factoryid: [{ required: true, message: '主制分厂不能为空', trigger: 'change' }]
        }
      },
      methods: {
        // 查询订单号
        searchMfgorderAsync(value, callback) {
          fetchSuggestion({ actionName: 'getMfgordernameAsync', name: 'mfgordername', value, callback })
        },
        // 查询件号
        searchProductAsync(value, callback) {
          fetchSuggestion({ actionName: 'getProductnameAsync', name: 'productname', value, callback })
        },
        // 查询批次号
        searchContainerAsync(value, callback) {
          fetchSuggestion({ actionName: 'getContainernameAsync', name: 'containername', value, callback })
        },
        //查询数据
        async getData() {
          this.$refs['queryInfoRef'].validate(async (valid) => {
            if (!valid) {
              return this.$message.error('必填项不能为空');
            } else {
              this.loading = true;
              this.loadingText = '数据加载中...';
              const { data: { data, meta, total } } = await axios.post('../handler/report/YPContainerStepCheckAndShipReport.ashx?action=getData', {
                type: 'getData',
                ...this.queryInfo
              })
              this.loading = false;
              if (meta.status === 500) {
                return this.$message.error(meta.msg);
              }
              this.dataList = data;
              this.total = total;
            }
          })
        },
        // 导出
        async getExportExcel() {
          const config = {
            url: '../handler/report/YPContainerStepCheckAndShipReport.ashx?action=getExportExcel',
            data: { type: 'getExportExcel', ...this.queryInfo }
          }
          exportExcelData(config, this);
        },
        handleCurrentChange(newPage) {
          this.queryInfo.currentPage = newPage;
          this.getData();
        },
        handleSizeChange(newSize) {
          this.queryInfo.pageSize = newSize;
          this.getData();
        }
      },
      async mounted() {
        this.factoryList = await getFactoryListByCode({ factoryCode: '608', isMapping: '是' });
        const { factoryid, factoryname } = this.factoryList[0];
        this.queryInfo.factoryid = factoryid;
        this.queryInfo.factoryname = factoryname;
        this.title = `${this.queryInfo.factoryname}零件流转信息查询报表`;
        document.title = this.title;
      },
      watch: { queryInfo: { handler() { this.queryInfo.currentPage = 1 }, deep: true } }
    })
  </script>
</body>

</html>